{extend name="index_layout"/}
{block name="main"}
<form class="layui-form" method="post">

    <div class="layui-form-item">
        <label class="layui-form-label">商品名称</label>
        <div class="layui-input-block">
            <input id="c-goods_name" lay-verify="required" disabled class=" layui-input" name="row[goods_name]" type="text" value="{$data.goods_name}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商品库存</label>
        <div class="layui-input-block">
            <input id="c-nums" lay-verify="required" disabled  class=" layui-input"  type="number" value="{$data.stock}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">成本单价</label>
        <div class="layui-input-block">
            <input  disabled lay-verify="required" class=" layui-input" step="0.01" name="row[cost_price]" type="number" value="{$data.stock_price}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">出库单价</label>
        <div class="layui-input-block">
            <input  disabled lay-verify="required" class=" layui-input" step="0.01" name="row[qutbound_price]" type="number" value="{$data.qutbound_price}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">出库数量</label>
        <div class="layui-input-block">
            <input  lay-verify="required" onblur="totalAmount()"  class=" layui-input" name="row[nums]" type="number" value="1">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">成本总价</label>
        <div class="layui-input-block">
            <input  disabled lay-verify="required" id="total_coset" class=" layui-input" step="0.01"  type="number" value="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">出库总价</label>
        <div class="layui-input-block">
            <input  id="total_qutbound" disabled lay-verify="required" class=" layui-input" step="0.01"  type="number" value="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">利润</label>
        <div class="layui-input-block">
            <input id="c-income" disabled lay-verify="required" class=" layui-input" step="0.01" name="row[income]" type="number" value="">
        </div>
    </div>
    <div class="layui-form-item layer-footer">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
{/block}
{block name="script"}
<script type="text/javascript">
layui.use('yznForm', function() {
    var yznForm = layui.yznForm;
    yznForm.bindevent($("form.layui-form"));
});


var cost_price = $('[name="row[cost_price]"]').val();
var qutbound_price = $('[name="row[qutbound_price]"]').val();
var nums = $('[name="row[nums]"]').val();





var total_coset = nums * cost_price
var total_qutbound = nums * qutbound_price
$("#total_coset").val(total_coset);
$("#total_qutbound").val(total_qutbound);


$('[name="row[income]"]').val(total_qutbound - total_coset);



function totalAmount() {
    var cost_price = $('[name="row[cost_price]"]').val();
    var qutbound_price = $('[name="row[qutbound_price]"]').val();
    var nums = $('[name="row[nums]"]').val();


    var total_coset = nums * cost_price
    var total_qutbound = nums * qutbound_price
    $("#total_coset").val(total_coset);
    $("#total_qutbound").val(total_qutbound);


    $('[name="row[income]"]').val(total_qutbound - total_coset);
}
</script>
{/block}